package com.ruin.tech.ahri.result;

/**
 * @program ahri
 * @description: 响应结果生成工厂类
 * @author: ruin
 * @create: 2019/06/25 08:16
 */
public class ResultFactory {

    public static Result buildSuccessResult(Object data){
        return buildResult(ResultCode.SUCCESS,"成功",data);
    }

    public static Result buildFailResult(String message){
        return buildResult(ResultCode.FAIL,message,null);
    }

    public static Result buildFailResult(ResultCode resultCode){
        return buildResult(resultCode.code,resultCode.message,null);
    }

    public static Result buildFailResult(ResultCode resultCode,String message){
        return buildResult(resultCode.code,message,null);
    }

    private static Result buildResult(ResultCode resultCode, String message, Object data) {
        return buildResult(resultCode.code,message,data);
    }

    private static Result buildResult(int code, String message, Object data) {
        return new Result(code,message,data);
    }
}
